{extend name="public:_base" /}
{block name="css"}
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/uploadify/uploadify.css">
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/css/fontcolor.css">
{/block}

{block name="js"}
{include file="public/_validform"}
<!--上传配置 -->
<script type="text/javascript" src="__STATIC__/admin/uploadify/jquery.uploadify.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/upfile.js"></script>

<!--验证-->
<script type="text/javascript">
    upload_image('image','','584','302','500');
    var URL = {
        uploader: '{:url('Upload/image')}',
        swf:'__STATIC__/admin/uploadify/uploadify.swf',
        ROOT:'__PUBLIC__/uploads/image',
        del_url:'{:url('Product/delimage')}',
    }

    // 获取字体颜色
    $("#fontcolor").on("input propertychange blur change",function () {
        var fontVal = $("#fontcolor").val();
        $('.fontcolor').attr('value', fontVal);
    })
</script>

<script type="text/javascript" src="__STATIC__/admin/js/tempname.js"></script>

<!-- 颜色取色器 -->
<script type="text/javascript" src="__STATIC__/admin/js/colorpicker/spectrum.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/colorpicker/color.js"></script>

<script>

    // 验证
    $(function () {
        $("[name='pid']").find("[value='{$data.pid ?? ''}']").attr("selected", true);
        $(".sp-preview-inner").attr("style", "background-color: {$data.fontcolor ??'#000'}");

        $('#pid').change(function(){
            var ss = $(this).children('option:selected').attr('id');
            $('#pids').attr('value', ss);
        });

        // 模版列表字母全部变成小写
        $(".tmplists option").each(function () {
            var listValue = ($(this).attr("value")).toLowerCase();
            $(this).attr("value",listValue);
        });

        $('#select').change(function(){

            // 所属模型字母全部变成小写
            var value = ($(this).children('option:selected').attr('value')).toLowerCase();

            // 每次选择, 增加相对应的selected值
            $(".templists option[value='"+value+'.html'+"']").prop("selected", true);
            $(".temparticles option[value='"+value+'detailed.html'+"']").prop("selected", true);
            
        });

        // 编辑栏目, 判断是否模版是否有值
        $("[name='templist']").find("[value='{$data.templist ?? ''}']").attr("selected", true);
        $("[name='temparticle']").find("[value='{$data.temparticle ?? ''}']").attr("selected", true);
        //显示page开头的
//        $("[value^='_']").css('display','none');
//        $("[value^='page']").css('display','none');
        {volist name="nav_model" id="vo"}
            $("[value^='{$key|strtolower}']").css('display','inline');
        {/volist}
    });
</script>

{/block}
{block name="main"}

<div class="page-container">
    <div class="Huialert Huialert-info">
        <i class="Hui-iconfont">&#xe6a6;</i>
        <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
        <ul>
            <li>所属模型一经添加不可修改</li>
        </ul>
    </div>
    <form action="{:url(\''.\\think\\Request::instance()->controller().'/save')}" method="post" class="form form-horizontal" id="form">
        
        <table class="table table-border table-bordered table-bg table-style">
            <thead>
                <tr>
                    <th colspan="2" scope="col">填写信息</th>
                </tr>
            </thead>

            <tbody>
                <tr>
                    <th>
                        导航级别：
                    </th>
                    <td>
                        <!--<span class="select-box"></span>-->
                        <select name="pid" id="pid" class="select">
                            <option value="0" id=",">新导航</option>
                            {volist name="getall" id="vo"}
                            <option value="{$vo.id}" id="{$vo.pids}" >{$vo['level']}{$vo.name}</option>
                            {/volist}
                        </select>
                    </td>
                </tr>

                <tr>
                    <th>
                        <span class="c-red">*</span>导航名：
                    </th>
                    <td>
                        <input type="text" class="input-text" value="{$data.name ?? ''}" placeholder="" datatype="*1-16" name="name">
                    </td>
                </tr>
                <tr>
                    <th>
                        简介：
                    </th>
                    <td>
                        <input type="text" class="input-text" value="{$data.brief ?? ''}" placeholder="产品简介" name="brief">
                    </td>
                </tr>
                <tr>
                    <th>
                        字体颜色：
                    </th>

                    <td>
                        <input id="fontcolor" />
                        <input class="fontcolor" name="fontcolor" value="{$data.fontcolor ?? '#000'}" style="display: none;">
                    </td>
                </tr>
                <tr>
                    <th>
                        图片584 * 302：
                    </th>
                    <td>
                        <div id="image_s">
                            {notempty name="$data.image"}
                            <img src="__PUBLIC__/uploads/{$data.image ?'image/'.$data.image: 'sm_125.jpg'}" />
                            {/notempty}
                        </div>
                        <input id="image_post" name="image" type="hidden" value="{$data.image ?? ''}"/>
                        <input name="old_image" type="hidden" value="{$data.image ?? ''}"/>
                        <input id="image" name="image_upload" type="file" multiple="true">
                    </td>
                </tr>
                <!--<tr>-->
                    <!--<th>-->
                        <!--<span class="c-red">*</span>英文名：-->
                    <!--</th>-->
                    <!--<td>-->
                        <!--<input type="text" class="input-text" value="{$data.Ename ?? ''}" placeholder="" datatype="*1-16" name="Ename">-->
                    <!--</td>-->
                <!--</tr>-->

                <tr>
                    <th>
                        <span class="c-red">*</span>所属模型：
                    </th>
                    <td>
                        {notempty name="$data.model"}
                        {$nav_model[$data.model]}
                        {else/}
                        <select name="model" id="select" class="select" datatype="*">
                            <option value="">--请选择--</option>
                            {volist name="nav_model" id="vo"}
                            <option value="{$key}">{$vo}</option>
                            {/volist}
                        </select>
                        {/notempty}
                    </td>
                </tr>

                <tr>
                    <th>
                        <span class="c-red">*</span>模板列表：
                    </th>
                    <td>
                        <select name="templist" id="templist select" class="templists select">
                            <option value="index">--请选择--</option>
                            {volist name="dirlist" id="vo"}
                            <option value="{$vo.name}" title="{$vo.name}" style="display: none">{$vo.name}</option>
                            {/volist}
                        </select>
                    </td>
                </tr>

                <tr>
                    <th>
                        <span class="c-red">*</span>模板内容：
                    </th>
                    <td>
                        <select name="temparticle" id="temparticle" class="temparticles select">
                            <option value="index">--请选择--</option>
                            {volist name="dirlist" id="vo"}
                            <option value="{$vo.name}" title="{$vo.name}" style="display: none">{$vo.name}</option>
                            {/volist}
                        </select>
                    </td>
                </tr>
            </tbody>
            
            <tfoot>
                <tr>
                    <th></th>
                    <td>
                        <input name="id" value="{$data.id ?? ''}" type="hidden">
                        <input name="type" value="model" type="hidden">
                        <input id="pids" name="pids" value="{$data.pids ?? ','}" type="hidden">
                        {:token()}
                        <input class="btn radius btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                    </td>
                </tr>
            </tfoot>

        </table>
        
    </form>
    
</div>
{/block}
